package classes.controlers {
	import classes.managers.Game_Manager;
	import flash.display.MovieClip;
	import flash.events.Event;
	/**
	 * ...
	 * @author Kihoonee
	 */
	public class Rabbit_Controler extends A_Controler {
		
		public function Rabbit_Controler( _gm:Game_Manager, _mc:MovieClip ) {
			super( _gm, _mc );
			
		}
		
		public function init():void {
			visibleManager( "nomal" );
		}
		
		public function sleep():void {
			visibleManager("sleep");
			mc.wakeUp_mc.gotoAndStop(1);
		}
		
		public function bang():void {
			visibleManager( "bang" );
			mc.bang_mc.gotoAndPlay(2);
			mc.bang_mc.addEventListener("bang_END", bang_END );
		}
		private function bang_END(e:Event):void {
			mc.bang_mc.removeEventListener("bang_END", bang_END );
			gm.bang_END();
			sleep();
		}
		
		public function middleBang():void {
			visibleManager( "middleBang" );
			mc.middleBang_mc.gotoAndPlay(2);
			mc.middleBang_mc.addEventListener("middleBang_END", middleBang_END );
		}
		private function middleBang_END(e:Event):void {
			mc.bang_mc.removeEventListener("middleBang_END", middleBang_END );
			gm.middleBang_END();
			sleep();
		}
		
		public function bigBang():void {
			visibleManager( "bigBang" );
			mc.bigBang_mc.gotoAndPlay(2);
			mc.bigBang_mc.addEventListener( "bigBang_END", bigBang_END );
		}
		private function bigBang_END(e:Event):void {
			mc.bigBang_mc.removeEventListener("bang_END", bang_END );
			gm.bigBang_END();
			sleep();
		}
		
		public function wakeUp():void {
			visibleManager( "wakeUp" );
			mc.wakeUp_mc.gotoAndPlay(2);
			mc.wakeUp_mc.addEventListener("wakeUp_END", wakeUp_END );
		}
		private function wakeUp_END(e:Event):void {
			mc.wakeUp_mc.removeEventListener("wakeUp_END", wakeUp_END );
			gm.gameOver();
		}
		
		public function visibleManager( _state:String):void {
			mc.nomal_mc.visible = false;
			mc.sleep_mc.visible = false;
			mc.wakeUp_mc.visible = false;
			mc.bang_mc.visible = false;
			mc.middleBang_mc.visible = false;
			mc.bigBang_mc.visible = false;
			
			switch (_state) {
				case "nomal": mc.nomal_mc.visible = true;
				break;
				case "sleep": mc.sleep_mc.visible = true;
				break;
				case "wakeUp": mc.wakeUp_mc.visible = true;
				break;
				case "bang": mc.bang_mc.visible = true;
				break;
				case "middleBang": mc.middleBang_mc.visible = true;
				break;
				case "bigBang": mc.bigBang_mc.visible = true;
				break;
				default:
			}
		}
		
		public function gameOver():void {
			mc.wakeUp_mc.gotoAndStop(1);
			mc.bang_mc.gotoAndStop(1);
			mc.bigBang_mc.gotoAndStop(1);
		}
	}

}